package com.easy.gao.mvptest.view;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

import com.easy.gao.mvptest.R;

import basemvp.BaseActivity;
import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
import login.MyPersenter;
import login.MyView;

public class MainActivity extends BaseActivity implements MyView {

    @BindView(R.id.tv)
    TextView tv;
    @BindView(R.id.btn)
    Button btn;
    MyPersenter myPersenter;
    @BindView(R.id.btn2)
    Button btn2;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        ButterKnife.bind(this);
        myPersenter = new MyPersenter();
        myPersenter.attachView(this);
    }

    @Override
    public void getData(String data) {
        tv.setText(data);
    }

    @Override
    protected void onDestroy() {
        myPersenter.detachView();
        super.onDestroy();
    }

    @OnClick({R.id.btn, R.id.btn2})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.btn:
                myPersenter.getData("0");
                break;
            case R.id.btn2:
                startActivity(new Intent(this,Main2Activity.class));
                break;
        }
    }
}
